<?php

namespace common\models\firstpage;

use common\models\common\Provinces;
use Yii;
use yii\behaviors\BlameableBehavior;
use yii\db\ActiveQuery;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
use common\helpers\HashidsHelper;
use common\enums\StatusEnum;
use common\models\base\User;
use common\helpers\RegularHelper;
use common\traits\Tree;


/**
 * This is the model class for table "{{%by_service}}
 *
 *
 * @package common\models\banner
 *
 */
class Subscribe extends ActiveRecord
{

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%by_subscribe}}';
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [

            [['id', 'address','time','describe','img'], 'safe'],
            [['status', 'created_at', 'updated_at','province_id','city_id','area_id'], 'integer']

        ];
    }



    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'address' => '地址',
            'time' => '上门时间',
            'describe' => '物品描述',
            'img' => '上传照片',
            'status' => '状态',
            'province_id' => 'Province ID',
            'city_id' => 'City ID',
            'area_id' => 'Area ID',
            'created_at' => '创建时间',
            'updated_at' => '修改时间',
        ];
    }


    public function getaddr()
    {
        return $this->hasOne(Address::class, ['id' => 'address_id']);
    }

    public function behaviors()
    {

        return [
            [
                'class' => TimestampBehavior::class,
                'attributes' => [
                    ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'],
                    ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at'],
                ],
            ]
        ];
    }
}
